<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" class="tl-dialog" width="1200px" @open="open" @close="close" top="10px" :append-to-body="true" :modal-append-to-body="true">
    <div style="padding-bottom:10px">
      <!-- 查询界面 -->
      <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false">
        <template slot="search">
          <el-form-item label="编码" prop="code">
            <el-input v-model="queryParam.qry_code" placeholder=""></el-input>
          </el-form-item>
          <el-form-item label="名称">
            <el-input v-model="queryParam.qry_name" placeholder=""></el-input>
          </el-form-item>
        </template>
      </tl-list-search>
      <!-- 列表界面 -->
      <div>
        <!-- 列表选择 -->
        <div class="table-alert-div" ref="selector">
          <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
            <template slot="title">
              已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRows.length }}</a>项&nbsp;&nbsp;
              <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
            </template>
          </el-alert>
        </div>
        <!--表格渲染-->
        <el-table class="tl-table" ref="mainTable" :height="tableHeight" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
          <el-table-column type="selection" width="55px" fixed="left" v-if="isSingleSelect === false "> </el-table-column>
          <el-table-column prop="dispprojectid" label="项目" width="100px" sortable="custom" sort-by="projectid" align="center" header-align="center"></el-table-column>
          <el-table-column prop="changereason" label="变更原因" width="150px" sortable="custom" sort-by="changereason" align="center" header-align="center"></el-table-column>
          <el-table-column prop="customername" label="客户名称(原)" width="120px" sortable="custom" sort-by="customername" align="center"></el-table-column>
          <el-table-column prop="customername2" label="客户名称(新)" width="120px" sortable="custom" sort-by="customername2" align="center"></el-table-column>
          <el-table-column prop="customercode" label="客户编号(原)" width="150px" sortable="custom" sort-by="customercode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="customercode2" label="客户编号(新)" width="150px" sortable="custom" sort-by="customercode2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="name" label="项目名称(原)" width="150px" sortable="custom" sort-by="name" align="center" header-align="center"></el-table-column>
          <el-table-column prop="name2" label="项目名称(新)" width="150px" sortable="custom" sort-by="name2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="projecttarget" label="项目目标(原)" width="150px" sortable="custom" sort-by="projecttarget" align="center" header-align="center"></el-table-column>
          <el-table-column prop="projecttarget2" label="项目目标(新)" width="150px" sortable="custom" sort-by="projecttarget2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="background" label="项目背景(原)" width="150px" sortable="custom" sort-by="background" align="center" header-align="center"></el-table-column>
          <el-table-column prop="background2" label="项目背景(新)" width="150px" sortable="custom" sort-by="background2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispprojectlevel" label="项目级别(原)" width="100px" sortable="custom" sort-by="projectlevel" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispprojectlevel2" label="项目级别(新)" width="100px" sortable="custom" sort-by="projectlevel2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="ownerorgname" label="所属公司名称(原)" width="120px" sortable="custom" sort-by="ownerorgname" align="center"></el-table-column>
          <el-table-column prop="ownerorgname2" label="所属公司名称(新)" width="120px" sortable="custom" sort-by="ownerorgname2" align="center"></el-table-column>
          <el-table-column prop="ownerorgcode" label="所属公司编码(原)" width="150px" sortable="custom" sort-by="ownerorgcode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="ownerorgcode2" label="所属公司编码(新)" width="150px" sortable="custom" sort-by="ownerorgcode2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="ownerdeptcode2" label="所属部门编码(新)" width="150px" sortable="custom" sort-by="ownerdeptcode2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="ownerdeptname" label="所属部门名称(原)" width="120px" sortable="custom" sort-by="ownerdeptname" align="center"></el-table-column>
          <el-table-column prop="ownerdeptname2" label="所属部门名称(新)" width="120px" sortable="custom" sort-by="ownerdeptname2" align="center"></el-table-column>
          <el-table-column prop="ownerdeptcode" label="所属部门编码(原)" width="150px" sortable="custom" sort-by="ownerdeptcode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="projectmanagername" label="项目经理(原)" width="120px" sortable="custom" sort-by="projectmanagername" align="center"></el-table-column>
          <el-table-column prop="projectmanagername2" label="项目经理(新)" width="120px" sortable="custom" sort-by="projectmanagername2" align="center"></el-table-column>
          <el-table-column prop="projectmanagercode" label="项目经理工号(原)" width="150px" sortable="custom" sort-by="projectmanagercode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="projectmanagercode2" label="项目经理工号(新)" width="150px" sortable="custom" sort-by="projectmanagercode2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="areamanagername" label="销售经理(原)" width="120px" sortable="custom" sort-by="areamanagername" align="center"></el-table-column>
          <el-table-column prop="areamanagername2" label="销售经理(新)" width="120px" sortable="custom" sort-by="areamanagername2" align="center"></el-table-column>
          <el-table-column prop="areamanagercode" label="销售经理工号(原)" width="150px" sortable="custom" sort-by="areamanagercode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="areamanagercode2" label="销售经理工号(新)" width="150px" sortable="custom" sort-by="areamanagercode2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="reason" label="承接原因(原)" width="150px" sortable="custom" sort-by="reason" align="center" header-align="center"></el-table-column>
          <el-table-column prop="reason2" label="承接原因(新)" width="150px" sortable="custom" sort-by="reason2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispcategory" label="项目类别(原)" width="100px" sortable="custom" sort-by="category" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispcategory2" label="项目类别(新)" width="100px" sortable="custom" sort-by="category2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="overview" label="项目概况(原)" width="150px" sortable="custom" sort-by="overview" align="center" header-align="center"></el-table-column>
          <el-table-column prop="overview2" label="项目概况(新)" width="150px" sortable="custom" sort-by="overview2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="projectmoney" label="项目金额(原)" width="150px" sortable="custom" sort-by="projectmoney" align="right" :formatter="moneyFormat" header-align="center"></el-table-column>
          <el-table-column prop="projectmoney2" label="项目金额(新)" width="150px" sortable="custom" sort-by="projectmoney2" align="right" :formatter="moneyFormat" header-align="center"></el-table-column>
          <el-table-column prop="planstarttime" label="计划开工时间(原)" width="170px" sortable="custom" sort-by="planstarttime" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="planstarttime2" label="计划开工时间(新)" width="170px" sortable="custom" sort-by="planstarttime2" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="planendtime" label="计划完工时间(原)" width="170px" sortable="custom" sort-by="planendtime" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="planendtime2" label="计划完工时间(新)" width="170px" sortable="custom" sort-by="planendtime2" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="dispisincludeproducts" label="是否需要我司提供产品(原)" width="100px" sortable="custom" sort-by="isincludeproducts" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispisincludeproducts2" label="是否需要我司提供产品(新)" width="100px" sortable="custom" sort-by="isincludeproducts2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="productdetails" label="产品明细(原)" width="150px" sortable="custom" sort-by="productdetails" align="center" header-align="center"></el-table-column>
          <el-table-column prop="productdetails2" label="产品明细(新)" width="150px" sortable="custom" sort-by="productdetails2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispispurchase" label="是否外包(原)" width="100px" sortable="custom" sort-by="ispurchase" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispispurchase2" label="是否外包(新)" width="100px" sortable="custom" sort-by="ispurchase2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="purchasedescription" label="外包说明(原)" width="150px" sortable="custom" sort-by="purchasedescription" align="center" header-align="center"></el-table-column>
          <el-table-column prop="purchasedescription2" label="外包说明(新)" width="150px" sortable="custom" sort-by="purchasedescription2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="mandays" label="人天估算(原)" width="80px" sortable="custom" sort-by="mandays" align="center" header-align="center"></el-table-column>
          <el-table-column prop="mandays2" label="人天估算(新)" width="80px" sortable="custom" sort-by="mandays2" align="center" header-align="center"></el-table-column>
          <el-table-column prop="orgname" label="申请公司" width="120px" sortable="custom" sort-by="orgname" align="center"></el-table-column>
          <el-table-column prop="orgcode" label="申请公司编码" width="150px" sortable="custom" sort-by="orgcode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="deptname" label="申请部门" width="120px" sortable="custom" sort-by="deptname" align="center"></el-table-column>
          <el-table-column prop="deptcode" label="申请部门编码" width="150px" sortable="custom" sort-by="deptcode" align="center" header-align="center"></el-table-column>
          <el-table-column prop="usercode" label="申请人工号" width="120px" sortable="custom" sort-by="usercode" align="center"></el-table-column>
          <el-table-column prop="username" label="申请人姓名" width="150px" sortable="custom" sort-by="username" align="center" header-align="center"></el-table-column>
          <el-table-column prop="docdate" label="单据日期" width="170px" sortable="custom" sort-by="docdate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="submitdate" label="提交日期" width="170px" sortable="custom" sort-by="submitdate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
          <el-table-column prop="docno" label="单据编号" width="150px" sortable="custom" sort-by="docno" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispflowid" label="审批流程" width="100px" sortable="custom" sort-by="flowid" align="center" header-align="center"></el-table-column>
          <el-table-column prop="latestphase" label="最新阶段" width="150px" sortable="custom" sort-by="latestphase" align="center" header-align="center"></el-table-column>
          <el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center"></el-table-column>
          <el-table-column prop="description" label="备注" min-width="250px" align="left" header-align="center"></el-table-column>
          <el-table-column prop="enabled" label="有效" width="100px" sortable="custom" sort-by="enabled" align="center" header-align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
              <el-tag v-else type="danger">否</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="80px" align="center" fixed="right" v-if="isSingleSelect === true">
            <template slot-scope="scope">
              <el-button type="text" icon="el-icon-finished" @click="doSelectData(scope.row[fieldDefaultKey])">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 列表分页 -->
        <el-row class="pagebar" ref="pager">
          <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
        </el-row>
      </div>
    </div>
    <div slot="footer" class="dialog-footer" v-if="isSingleSelect === false">
      <el-button type="text" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doConfirm">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_ref_list } from '@tapui/mixins/mixin_ref_list'
/** 子组件 */
/** 工具类 */
import { queryDataCode } from '@tapui/api/dataCode'
import { getAction, putAction, postAction } from '@tapui/utils/http'
import { rmbFormat } from "../../../utils/calculation"
/** VUE配置 */
export default {
  name: 'TlPmProjectChangeRef',
  components: {},
  mixins: [mixin_ref_list],
  data() {
    return {
      description: '项目基本信息变更申请参照页面',
      // 默认Key字段名
      fieldDefaultKey: 'id',
      // 默认显示字段名
      fieldDefaultValue: 'name',
      // url配置
      url: {
        list: '/pm/projectChange/refList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      }
    }
  },
  methods: {
    moneyFormat(row, column, cellValue, index) {
      return rmbFormat(row[column.property])
    }
  }
}
</script>

